package com.github.common.extend.demo.config.json;

import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.github.common.extend.demo.config.json.jaskson.precision.DecimalPrecisionSerializer;

import java.lang.annotation.*;
import java.math.RoundingMode;

/**
 * fastjson框架序列化的时候浮点数精度处理
 * @author X1993
 * @date 2022/7/25
 * @description
 */
@Documented
@Target({ElementType.FIELD ,ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotationsInside
@JsonSerialize(using = DecimalPrecisionSerializer.class)
public @interface DecimalPrecision {

    /**
     * 保留的小数精度
     * @return
     */
    int value() default 2;

    RoundingMode roundingMode() default RoundingMode.HALF_UP;

}
